package com.wzw.springboot.principle.mvc.message;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.IOException;
import java.io.InputStream;

/**
 * Spring MVC 对HTTP请求消息的拦截机制
 * 在JSON数据格式下，可配合Advice接口使用
 *
 * @author Wangzhiwen
 */
public class CustomizedHttpInputMessage implements HttpInputMessage {

    private final InputStream body;

    private final HttpHeaders headers;

    public CustomizedHttpInputMessage(InputStream body, HttpHeaders headers) {
        this.body = body;
        this.headers = headers;
    }

    @Override
    public InputStream getBody() throws IOException {
        return body;
    }

    @Override
    public HttpHeaders getHeaders() {
        return headers;
    }
}
